#define _XOPEN_SOURCE 500  
#define LOG_MAX_MESSAGE_LENGTH 2048 
       
#include <stdio.h>         
#include <pthread.h>          
#include <stdarg.h>           

typedef enum {
	M_CONSOLE_DISABLE = 1,
	M_CONSOLE_ENABLE = 2
} e_console_mode;

typedef enum {
	ERRORs = 1,
	WARNINGs = 2,
	INFOs = 4,
	DEBUGs = 8
} e_message_level;

typedef struct {
	FILE* file;
	char *program_name;
	int program_pid;
	unsigned char log_levels;
	e_console_mode console_mode;
	pthread_mutex_t mutex;
} t_log;
	

t_log*  log_create(const char *program_name, const char* file_name, unsigned char log_levels, e_console_mode console_mode);    
int     log_info(t_log* log, const char *thread_name, const char *format, ... );       
int     log_warning(t_log* log, const char *thread_name, const char *format, ... );         
int     log_error(t_log* log, const char *thread_name, const char *format, ... );         
int     log_debug(t_log* log, const char *thread_name, const char *format, ... );  
#define log_has_level(log, level) ((log->log_levels & level) == level)                
void    log_destroy(t_log *log);  


